package com.skyon.rule.res.spring.grid;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class GridImpl implements Grid {
	
	private Map<String, GridNode> localNodes = new HashMap<String, GridNode>();
	private String id;

	public GridImpl() {
		this.setId(UUID.randomUUID().toString());
		init();
	}

	private void init() {
		
	}

	public Object get(String str) {
		return this.localNodes.get(str);
	}

	public <T> T get(Class<T> serviceClass) {
		throw new UnsupportedOperationException();
	}

	public GridNode createGridNode(String id) {
		GridNode node = new GridNodeImpl(id);
		this.localNodes.put(id, node);
		return node;
	}

	public void removeGridNode(String id) {

		this.localNodes.remove(id);
	}

	public GridNode getGridNode(String id) {
		return this.localNodes.get(id);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

}
